Skip to content

docs: clarify a caveat with COPY --link and overwriting directory permissions#6778

Open
jsternberg wants to merge 1 commit into
moby:masterfrom
jsternberg:copy-link-clarify-permission-overwriting
Open

docs: clarify a caveat with COPY --link and overwriting directory permissions#6778
jsternberg wants to merge 1 commit into
moby:masterfrom
jsternberg:copy-link-clarify-permission-overwriting

Conversation

@jsternberg
Copy link
Copy Markdown
Collaborator

Closes #3602.

Comment thread frontend/dockerfile/docs/reference.md Outdated
conditions for cache reuse.

When copying a path into a subdirectory, `--link` will always create the
parent directories with the default directory creation settings and will always
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

always create the
parent directories with the default directory creation settings

I think it creates the parent directories in whatever settings that were set by the copy command.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My observed behavior was that parent directories were created with 0755. I'm not sure if that's what's intended but it was the behavior I saw.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be the same as COPY without --link on top of scratch stage.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may be related to umask. I tested this on a Mac with Docker Desktop and the VM seems to have a umask of 0022 which may have influenced the results. The code to create these directories seems to be intended to use the --chmod setting but umask may have interfered here.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made a note about umask in the COPY --chmod section and how it can affect creating parent directories.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Umask of the system should never affect the output of buildkit. We are clearing umask in https://github.com/moby/buildkit/blob/master/cmd/buildkitd/main_unix.go#L19

…ermissions

Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
@jsternberg jsternberg force-pushed the copy-link-clarify-permission-overwriting branch from 9b10935 to d87c25f Compare May 15, 2026 15:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

COPY command changes the directory permissions to change.

2 participants